package com.bfly.mall.product.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.bfly.core.base.entity.BaseEntity;
import com.bfly.mall.product.enums.PricingMethodEnum;

import java.io.Serializable;
import java.util.List;

/**
 * 运价模板
 *
 * @author 长沙商脉科技有限公司
 * @date 2020/9/15 21:02
 */
@TableName(value = "freight_template",resultMap = "FreightTemplateResultMap")
public class FreightTemplate extends BaseEntity implements Serializable {

    private static final long serialVersionUID = -830212872151409300L;
    /**
     * 运费模板名称
     *
     * @author 长沙商脉科技有限公司
     * @date 2020/4/27 10:36
     */
    @TableField("name")
    private String name;

    /**
     * 是否包邮
     *
     * @author 长沙商脉科技有限公司
     * @date 2020/4/27 10:37
     */
    @TableField("is_free_shipping")
    private boolean freeShipping;

    /**
     * 计价方式
     *
     * @author 长沙商脉科技有限公司
     * @date 2020/4/27 10:38
     * @see com.bfly.mall.product.enums.PricingMethodEnum
     */
    @TableField("pricing_method")
    private int pricingMethod;

    /**
     * 是否指定条件包邮
     *
     * @author 长沙商脉科技有限公司
     * @date 2020/4/27 10:38
     */
    @TableField("is_free_conditions")
    private boolean freeConditions;

    /**
     * 包邮条件
     *
     * @author 长沙商脉科技有限公司
     * @date 2020/4/27 10:49
     */
    @TableField(exist = false)
    private List<FreightFreeConditions> conditions;

    /**
     * 运费模板计价方式
     *
     * @author 长沙商脉科技有限公司
     * @date 2020/4/27 11:14
     */
    @TableField(exist = false)
    private List<FreightTemplatePricing> pricings;

    /**
     * 是否删除
     *
     * @author 长沙商脉科技有限公司
     * @date 2020/4/27 14:44
     */
    @TableField("is_deleted")
    private boolean deleted;

    @TableField("create_ip")
    private String createIp;

    public String getPricingMethodName() {
        PricingMethodEnum type = PricingMethodEnum.getPricingMethod(getPricingMethod());
        return type == null ? "" : type.getName();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isFreeShipping() {
        return freeShipping;
    }

    public void setFreeShipping(boolean freeShipping) {
        this.freeShipping = freeShipping;
    }

    public int getPricingMethod() {
        return pricingMethod;
    }

    public void setPricingMethod(int pricingMethod) {
        this.pricingMethod = pricingMethod;
    }

    public boolean isFreeConditions() {
        return freeConditions;
    }

    public void setFreeConditions(boolean freeConditions) {
        this.freeConditions = freeConditions;
    }

    public List<FreightFreeConditions> getConditions() {
        return conditions;
    }

    public void setConditions(List<FreightFreeConditions> conditions) {
        this.conditions = conditions;
    }

    public List<FreightTemplatePricing> getPricings() {
        return pricings;
    }

    public void setPricings(List<FreightTemplatePricing> pricings) {
        this.pricings = pricings;
    }

    public boolean isDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }

    public String getCreateIp() {
        return createIp;
    }

    public void setCreateIp(String createIp) {
        this.createIp = createIp;
    }
}
